using Microsoft.AspNetCore.Mvc;
using zhwy.saas.api.Entity.Sys;
using zhwy.saas.api.Models;
using zhwy.saas.api.Services.Sinterface.Sys;

namespace zhwy.saas.api.Controllers.V1.Sys
{
    /// <summary>
    /// 系统用户管理
    /// </summary>
    [ApiVersion("1.0")]
    public class SysUserController : BaseController<UsersEntity>
    {
        private readonly ISysUserService _sysUserService;

        public SysUserController(ISysUserService sysUserService)
            : base(sysUserService)
        {
            _sysUserService = sysUserService;
        }

        /// <summary>
        /// 检查用户帐号是否存在
        /// </summary>
        /// <param name="username">帐号</param>
        /// <returns>是否存在</returns>
        [HttpGet("username")]
        public async Task<ApiResponseModel<bool>> CheckUserName([FromQuery] string username)
        {
            var result = await _sysUserService.CheckUserNameExists(username);
            return GetResponseModel<bool>(result);
        }

        ///// <summary>
        ///// 修改用户密码
        ///// </summary>
        ///// <param name="id">用户ID</param>
        ///// <param name="newPassword">新密码</param>
        ///// <returns>修改结果</returns>
        ///// <response code="200">密码修改成功</response>
        ///// <response code="400">密码修改失败</response>
        //[HttpPut("{id}/password")]
        //[ProducesResponseType(typeof(ApiResponseModel<bool>), 200)]
        //[ProducesResponseType(typeof(ApiResponseModel<bool>), 400)]
        //public async Task<ActionResult<ApiResponseModel<bool>>> ChangePassword(long id, [FromBody] string newPassword)
        //{
        //    var result = await _sysUserService.ChangePasswordAsync(id, newPassword);
        //    return result
        //        ? ApiResponseModel<bool>.Ok(true, "密码修改成功")
        //        : ApiResponseModel<bool>.Error("密码修改失败");
        //}

        ///// <summary>
        ///// 更新用户状态
        ///// </summary>
        ///// <param name="id">用户ID</param>
        ///// <param name="status">新状态</param>
        ///// <returns>更新结果</returns>
        ///// <response code="200">状态更新成功</response>
        ///// <response code="400">状态更新失败</response>
        //[HttpPut("{id}/status")]
        //[ProducesResponseType(typeof(ApiResponseModel<bool>), 200)]
        //[ProducesResponseType(typeof(ApiResponseModel<bool>), 400)]
        //public async Task<ActionResult<ApiResponseModel<bool>>> UpdateStatus(long id, [FromBody] int status)
        //{
        //    var result = await _sysUserService.UpdateStatusAsync(id, status);
        //    return result
        //        ? ApiResponseModel<bool>.Ok(true, "状态更新成功")
        //        : ApiResponseModel<bool>.Error("状态更新失败");
        //}

    }
}